package org.jackysoft.struts2.workflow;

import java.util.Collection;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.InterceptorRefs;
import org.apache.struts2.convention.annotation.Namespace;
import org.jackysoft.entity.WorkflowSetting;
import org.jackysoft.service.WorkflowSettingService;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;


@Controller
@Namespace("/workflow/setting")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
@InterceptorRefs({ @InterceptorRef("defaultStack"),
		@InterceptorRef("annotationWorkflow") })
public class WorkflowSettingAction 
extends AbstractWorkflowAction<WorkflowSetting> {

	private static final long serialVersionUID = 4974996239355662812L;
    private WorkflowSettingService service;
    private WorkflowSetting bean;
    private Collection<WorkflowSetting> beans;
    
    
      
    @Override  
    public String add()throws Exception{
    	service.create(beans);
    	return "add";
    }
    
    @Override 
    public String update()throws Exception{
    	service.update(beans);
    	return "update";
    }    
    
    @Override
    public String gets()throws Exception{
    	beans = service.getsByName(workflowName.getWorkflowName());
    	return SUCCESS;
    }  
    
    @Override 
    public String get()throws Exception{
    	bean = service.get(bean.getId());  	
    	return BEANDATA;
    }
   
    @Resource
	public void setService(WorkflowSettingService service) {
		this.setDataProvider(service);
		this.service = service;
	}
	public WorkflowSettingService getService() {
		return service;
	}
	public void setBean(WorkflowSetting bean) {
		this.bean = bean;
	}
	public WorkflowSetting getBean() {
		return bean;
	}
	public void setBeans(Collection<WorkflowSetting> beans) {
		this.beans = beans;
	}
	public Collection<WorkflowSetting> getBeans() {
		return beans;
	}

}
